package com.lyd.proxy;

/**
 * @Author:lyd
 * 静态代理类举例
 **/
public class StaticProxyTest {
    public static void main(String[] args) {
        //创建被代理类对象
        ClothFactory nike = new NikeClothProxy();
        //创建代理类对象
        ClothFactory proxy = new ProxyClothFactory(nike);
        proxy.produceCloth();

    }
}
interface ClothFactory{
    void produceCloth();

}

//代理类
class ProxyClothFactory implements ClothFactory {

    private ClothFactory clothFactory;

    public ProxyClothFactory(ClothFactory clothFactory) {
        this.clothFactory = clothFactory;
    }

    @Override
    public void produceCloth() {
        System.out.println("代理工厂做一些准备工作");
        clothFactory.produceCloth();
        System.out.println("代理工厂处理后续的收尾工作");
    }

}

//被代理类
class NikeClothProxy implements ClothFactory{

    @Override
    public void produceCloth() {
        System.out.println("NIKE生产AJ鞋子");
    }
}


